package com.kk;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.stage.Stage;

/**
 * 作者: 柯神_
 * 时间: 23:45
 * 日期: 2021/11/4
 * User: o_o 展示窗口、父子窗口操作
 **/
public class Launch extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {

        primaryStage.setTitle("我的JavaFx");
        primaryStage.getIcons().add(new Image("https://images.cnblogs.com/cnblogs_com/qqkkOvO/1881525/o_2011140113216ed27b3dedd8e816.jpg"));
        primaryStage.setResizable(true);

        // 监听窗口的长度
        primaryStage.heightProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                System.out.println("y: " + newValue.doubleValue());
            }
        });

        primaryStage.widthProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                System.out.println("X: " + newValue.doubleValue());
            }
        });

        primaryStage.setFullScreen(true);
        primaryStage.setScene(new Scene(new Group()));
        primaryStage.show();


//        子窗口
        Stage s1 = new Stage();
        s1.initOwner(primaryStage);
        s1.initModality(Modality.APPLICATION_MODAL);
        s1.show();
    }
}
